//
// Created by SDSC\202100300261 on 23-11-16.
//

#ifndef COMPILER_CODETABLE_H
#define COMPILER_CODETABLE_H

#include <string>
#include <vector>
#include <ostream>
enum class OPTS  {
    LIT,
    LOD,
    STO,
    CAL,
    INT,
    JMP,
    JPC,
    OPR

};
std::ostream& operator<<(std::ostream& os, const OPTS& value);
std::string nameOpt(OPTS opt);

class CodeEntry {
public:
    CodeEntry(OPTS _opt,int _level,int _adr,int _index);
    friend std::ostream& operator<<(std::ostream& os,const CodeEntry& obj);
    OPTS opt;
    int level;
    int adr;
    int index;
};

class CodeTable {
public:
    std::vector<CodeEntry> codeTable;
    int getIndex();
    int addCode(OPTS opt,int level,int adr);
    void setCode(int index,OPTS opt,int level,int adr);
    friend std::ostream& operator<<(std::ostream& os,const CodeTable& obj);
};


#endif //COMPILER_CODETABLE_H
